<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:include page="../include/header.jsp"></jsp:include>
<script type="text/javascript">
   $(function(){
	   var url = "jqGrid/queryPage/user_mgr_list.do";
	   $("#jqGrid").jqGridUtils({
			"url":url,
			"colModel":[{label: "ID",name: "id", hidden:true, key:true},
			            {label: "用户名" ,name: "username",width:100},
			            {label: "姓名" ,name: "fullName",width:100},
			            {label: "所属部门" ,name: "orgName",width:150},
			            {label: "联系电话" ,name: "phoneNum",width:100},
			            {label: "邮箱地址" ,name: "email",width:150},
			            {label: "状态" ,name: "state",width:80},
			            {label: "序号" ,name: "state",width:80},
			            {label: "创建时间" ,name: "createTime",width:150}],
			//caption: "用户管理",
			tableTitleIcon: "fa-users",
			"gridview":true,
			"rowNum":${pageSize},
			tableStyle:"table table-bordered",
			"scrollrows":true,
			multiselect: true,
			toolbar:[true,"top","#jqGrid-search"],
			"datatype":"json",
			"pager":"#jqGridPager"
		});
	   $("#jqGrid").jqGrid('navGrid','#jqGridPager',
			   {add:true,addfunc: function(){
				   //弹出窗口
				   window.parent.BootstrapDialogUtil.loadUriSubmitDialog('添加用户', 'user/add.do?jqGridId=jqGrid', 'fa fa-user-plus', null, null, function(){
					   window.parent.MixElementListener.initEvent();
				   });
			   }, edit:true,editfunc: function(){
				   //获取选中数据
				   var id = $("#jqGrid").jqGrid('getGridParam','selrow');
				   id = utils.handleNull(id);
				   if(utils.isEmpty(id)) {
					   window.parent.BootstrapDialogUtil.warningAlert(null,"请选择一条要编辑的数据！");
				   } else {
					   window.parent.BootstrapDialogUtil.loadUriSubmitDialog('修改用户', 'user/edit.do?id='+id+'&jqGridId=jqGrid', 'fa fa-pencil-square-o', null, null, function(){
						   window.parent.MixElementListener.initEvent();
					   });
				   }
			   }, del:true,delfunc:function(){
				 //获取选中数据
				 var ids = $("#jqGrid").jqGrid('getGridParam','selarrrow');
				 if(ids.length == 0) {
					 window.parent.BootstrapDialogUtil.warningAlert(null,"请选择要删除的数据！");
				 } else {
					 window.parent.BootstrapDialogUtil.delDialog(null,"选中的用户",'user/delete.do',ids.join(','),function(){
						 //$("#jqGrid").trigger("reloadGrid");
						 refreshJqGrid();
					 });
				 }
			   }, view:false, search:false},{id:'edit'},{id:'add'});
	   $(".mix-jqgrid-search").click(function(){
		   var $form = $(this).parents("form:eq(0)");
		   var params = $form.serialize();
		   $("#jqGrid").jqGrid('setGridParam',{url:url+"?"+params,page:1}).trigger("reloadGrid"); //重新载入  
	   });
   });
   //刷新列表
   function refreshJqGrid() {
	   $("#jqGrid").trigger("reloadGrid");
   }
</script>
    <table id="jqGrid"></table>
    <div id="jqGridPager"></div>
    <div class="search-panel" id="jqGrid-search">
      <form class="form-inline">
      	 <div class="form-group">
		    <label for="input01">名称</label>
		    <input type="text" name="name" class="form-control input-sm" id="input01" placeholder="用户名或姓名" />
		 </div>
		  <div class="form-group">
		    <label for="input02">所在机构</label>
		    <input name="type" id="input02" class="mix-input-tree form-control input-sm" name="orgId" data-uri="query/ztree/select_org_tree.do" data-is-show-none="yes" />
		  </div>
		  <button type="button" class="btn btn-info btn-sm mix-jqgrid-search"><i class="fa fa-search"></i> 搜索</button>
      </form>
    </div>
<jsp:include page="../include/footer.jsp"></jsp:include>
